package com.mystudy.concurrent.base;

import java.util.stream.IntStream;

/**
 * TODO:线程的join方法测试
 * 调用join的线程执行完了之后，才会执行被加入的线程
 * @author acy
 * @since 2019/05/10 17:26
 */
public class ThreadJoinTest {
	public static void main(String[] args) throws InterruptedException {
		Thread thread = new Thread(() -> {
			IntStream.range(1, 1000).forEach(item -> System.out.println(Thread.currentThread().getName() + "---->" + item));
		});
		Thread thread2 = new Thread(() -> {
			IntStream.range(1, 1000).forEach(item -> System.out.println(Thread.currentThread().getName() + "---->" + item));
		});
		thread.start();
		thread.join();
		thread2.start();
		thread2.join();
		IntStream.range(1, 1000).forEach(item -> System.out.println(Thread.currentThread().getName() + "---->" + item));
	}
}
